import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:largefriends/pages/lf_chat_detail/widget/sticker_helper.dart';
import 'package:largefriends/res/lf_double_ext.dart';

import '../../../entity/entities/chat_new_message_entity.dart';
import '../../../res.dart';
import '../../../service/lf_auth_service.dart';
import 'LfMessageMenu.dart';

class LfMessageStickerAnim extends StatelessWidget {
  final ChatNewMessageEntity data;
  final Function() recall;
  final Function() report;
  final bool canShowMenu;
  const LfMessageStickerAnim({
    Key? key,
    required this.data,
    required this.recall,
    required this.report,
    required this.canShowMenu,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    LfAuthService authService = Get.find();
    var isSender =
        data.sender?.profile?.userId == authService.currentAccount!.userId;
    var path = stickerAnim[data.message!] ?? Res.huaxin;

    ///强行设置一个,免得动画不支持
    var child = getMenuWidget(
        data: data,
        child: Image.asset(path, width: 60.r, height: 60.r),
        isSender: isSender,
        recall: recall,
        report: report,
        canShowMenu: canShowMenu,
        reply: () {},
        isTextMessage: false);

    if (isSender) {
      return Row(
        mainAxisAlignment: MainAxisAlignment.end,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [Flexible(child: child), 10.w.sbw],
      );
    } else {
      return Row(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [10.w.sbw, Flexible(child: child), 10.w.sbw],
      );
    }
  }
}
